<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
  	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品详情</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
		<!-- 头部信息 -->
		<jsp:include page="header.jsp"></jsp:include>

		<!-- 商品搜索区 -->
		<jsp:include page="product-search.jsp"></jsp:include>

		<!-- 内容区域 -->
		<div class="container-fluid" style="margin: 30px;">
			<div class="col-xs-8" style="border: 1px solid gray;border-radius: 8px;height: 500px;">
				<!-- 商品详情(编辑商品) -->
				<div>
					<h2>编辑商品</h2>
					<form class="form-inline" action="${pageContext.request.contextPath}/product/update.do" method="POST">
						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>商品id</label>
							<input type="hidden" name="productId" value="${product.productId}">
							<input type="text" class="form-control" id="" readonly name="productId" value="${product.productId}" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>编号</label>
							<input type="text" class="form-control" value="${product.productNum}" name="productNum" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>名称</label>
							<input type="text" class="form-control" value="${product.productName}" name="productName" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>类别</label>
							<select class="form-control" name="categoryId">
								<c:forEach items="${categoryList}" var="category">
									<c:if test="${category.categoryId==product.categoryId}">
										<option value="${category.categoryId}" selected>${category.categoryName}</option>
									</c:if>
									<c:if test="${category.categoryId!=product.categoryId}">
										<option value="${category.categoryId}">${category.categoryName}</option>
									</c:if>
									
								</c:forEach>
							</select>
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>价格</label>
							<input type="number" class="form-control" value="${product.price}" name="price" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>折扣</label>
							<input type="number" class="form-control" value="${product.discount}" name="discount" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>新品推荐</label>
							<select class="form-control" name="isNew">
							<c:if test="${product.isNew==1}">
								<option value="1" selected>是</option>
								<option value="0">否</option>
							</c:if>
							<c:if test="${product.isNew==0}">
								<option value="1">是</option>
								<option value="0" selected>否</option>
							</c:if>
							</select>
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>低价促销</label>
							<select class="form-control" name="isCommend">
								<c:if test="${product.isCommend==1}">
									<option value="1" selected>是</option>
									<option value="0" >否</option>
								</c:if>
								<c:if test="${product.isCommend==0}">
									<option value="1">是</option>
									<option value="0" selected>否</option>
								</c:if>
							</select>
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>商品库存</label>
							<input type="number" class="form-control" value="${product.stock}" name="stock" style="widows: 300px;">
						</div>

						<div class="form-group col-xs-5 col-xs-offset-1" style="margin-top: 20px;">
							<label>商品描述</label>
							<textarea rows="3" class="form-control" cols="30" name="productDesc">${product.productDesc}</textarea>
						</div>

						<div class="form-group col-xs-5 col-xs-offset-9" style="margin-top: 60px;">
							<label>操作</label>
							<button type="submit" class="btn btn-primary">更新</button>
							<button type="button" class="btn btn-danger" onclick="location.href='${pageContext.request.contextPath}/product/delete.do?productId=${product.productId}'">删除</button>
						</div>
					</form>
				</div>
			</div>


			<div class="col-xs-1"></div>
			
			<!-- 添加商品 -->
			<jsp:include page="product-add.jsp"></jsp:include>
			</div>
	</body>
</html>